package spms.data.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import spms.data.entity.User;
import spms.data.service.UserService;
import spms.util.Page;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "User")
@RestController
public class UserController {

    @Resource
    private UserService userService;

    @ApiOperation(value = "查询所有用户")
    @GetMapping("/user/findAll")
    public List<User> findUserAll() throws Exception {
        return userService.findAll(User.class);
    }

    @ApiOperation(value = "通过userId查询用户")
    @GetMapping(value = "/user/findByUserId")
    public Object findByUserId(@RequestParam Integer id) {
        return userService.findByUserId(id);
    }

    @ApiOperation(value = "分页查询用户")
    @GetMapping(value = "/user/findPage")
    public Page<User> findUserPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize) throws Exception {
        return userService.findPage(pageNum, pageSize, User.class);
    }
}
